package com.github.catvod.spider.merge;

import java.nio.charset.Charset;

/* loaded from: classes.dex */
public class W {
    private static final Charset h = i.V0;
    private static final byte[] V0 = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51};

    private static class Tw {
        int h;

        Tw(int i) {
            this.h = i;
        }
    }

    public static byte[] V0(byte[] bArr, int i, int i2) {
        if (kb.h(bArr)) {
            return bArr;
        }
        Tw tw = new Tw(i);
        int i3 = (i + i2) - 1;
        int i4 = 0;
        int i5 = (i2 * 3) / 4;
        byte[] bArr2 = new byte[i5];
        while (tw.h <= i3) {
            byte j = j(bArr, tw, i3);
            byte j2 = j(bArr, tw, i3);
            byte j3 = j(bArr, tw, i3);
            byte j4 = j(bArr, tw, i3);
            if (-2 != j2) {
                bArr2[i4] = (byte) ((j << 2) | (j2 >>> 4));
                i4++;
            }
            if (-2 != j3) {
                bArr2[i4] = (byte) (((j2 & 15) << 4) | (j3 >>> 2));
                i4++;
            }
            if (-2 != j4) {
                bArr2[i4] = (byte) (((j3 & 3) << 6) | j4);
                i4++;
            }
        }
        return i4 == i5 ? bArr2 : (byte[]) j.V0(bArr2, new byte[i4], i4);
    }

    public static byte[] h(byte[] bArr) {
        return kb.h(bArr) ? bArr : V0(bArr, 0, bArr.length);
    }

    private static byte j(byte[] bArr, Tw tw, int i) {
        byte b;
        while (true) {
            int i2 = tw.h;
            if (i2 > i) {
                return (byte) -2;
            }
            tw.h = i2 + 1;
            byte b2 = bArr[i2];
            if (b2 > -1 && (b = V0[b2]) > -1) {
                return b;
            }
        }
    }
}
